<?php
namespace app\api\controller;

class RepayRecord extends Permission
{
    public function getList()
    {
        $page = isset($this->input_data['page']) ? $this->input_data['page'] : 1;
        $limit = isset($this->input_data['limit']) ? $this->input_data['limit'] : 15;
        $map = [];

        if( isset($this->input_data['relation_id']) && $this->input_data['relation_id'] != '') $map['relation_id'] = $this->input_data['relation_id'];

        if( isset($this->input_data['type']) && $this->input_data['type'] != '全部') $map['type'] = ['LIKE','%'.$this->input_data['type'].'%'];
        if( isset($this->input_data['cate']) && $this->input_data['cate'] != '全部') $map['cate'] = ['LIKE','%'.$this->input_data['cate'].'%'];

        $total = db('RepayRecord')->where($map)->count();
        $rows = db('RepayRecord')->order('id', 'DESC')->page($page,$limit)->where($map)->select();

        $list = [];
        foreach ($rows as $v) {

            $v['amount'] = formatMoneyShow($v['amount']);

            $v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
            
            $list[] = $v;
        }
        
        $data = [
            'total' => $total,
            'list' => $list
        ];
        $this->resSuc($data);
    }
  

}
